package com.zx.cloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zx.cloud.ApiVersion;
import com.zx.cloud.RequestLogging;
import com.zx.cloud.common.filter.IgnoreAuth;
import com.zx.cloud.controller.client.CallbackClient;
import com.zx.cloud.domain.BusinessNoticeBean;
import com.zx.cloud.domain.NotifyResponseBean;
import com.zx.cloud.model.response.ObjectDataResponse;

import io.swagger.annotations.ApiOperation;

/**
 * @Description:
 *
 * @author       Yan Weiwei
 * @Create Time: 2017年11月20日下午4:41:05
 */
@RestController
@RequestMapping(value = ApiVersion.API_V1_PREFIX+"/payfor")
public class CallbackController {
	
	@Autowired
	private CallbackClient callbackClient;

	@IgnoreAuth
	@RequestLogging
	@ApiOperation(value = "异步获取付款申请时回调方法" , notes = "异步获取付款申请时回调方法")
	@RequestMapping(value = "/receiveNotify", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<NotifyResponseBean> receiveNotify(@RequestBody BusinessNoticeBean businessNoticeBean) throws Exception{
		
		ObjectDataResponse<NotifyResponseBean> data = callbackClient.receiveNotify(businessNoticeBean);
		
		return data;
	}
	
	@IgnoreAuth
	@ApiOperation(value = "异步获取付款时回调方法" , notes = "异步获取付款时回调方法")
	@RequestMapping(value = "/receiveConfirmNotify", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<NotifyResponseBean> receiveConfirmNotify(@RequestBody BusinessNoticeBean businessNoticeBean) throws Exception{
		
		ObjectDataResponse<NotifyResponseBean> data = callbackClient.receiveConfirmNotify(businessNoticeBean);
		
		return data;
	}
	
	@IgnoreAuth
	@ApiOperation(value = "异步获取银行卡还款回调方法" , notes = "异步获取银行卡还款回调方法")
	@RequestMapping(value = "/receiveRepaymentNotify", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<NotifyResponseBean> receiveRepaymentNotify(@RequestBody BusinessNoticeBean businessNoticeBean) throws Exception{
		
		ObjectDataResponse<NotifyResponseBean> data = callbackClient.receiveRepaymentNotify(businessNoticeBean);
		
		return data;
	}
}
